package cn.darkhorse.workorder;

import cn.darkhorse.workorder.domain.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

/**
 * 业务操作类型
 *
 * @author ruoyi
 */

@Getter
public enum SignTypeEnum
{
    d_administrator(0,"取送样品交接", "administrator_sign_delivery","样品管理员", new QmsWorkorderSampleDelivery(), "administratorSign"),
    s_administrator(1, "感官检验", "balance_administrator_sign_sense", "样品管理员", new QmsWorkorderSense(),"sampleAdministratorSign"),
    s_inspector(1, "感官检验","sense_inspector_sign_sense", "感官检验员",new QmsWorkorderSense() ,"senseInspectorSign"),
    s_principal(1, "感官检验","sense_principal_sign", "感官检验负责人", new QmsWorkorderSense() ,"sensePrincipalSign"),
//    b_principal("2", "样品平衡","principal_sign", "感官检验负责人",new QueryWrapper<QmsWorkorderSampleBalance>() ,"principalSign"),
    b_administrator(2, "样品平衡","balance_administrator_sign_balance","样品管理员", new QmsWorkorderSampleBalance(),"sampleBalanceAdministratorSign"),
    b_inspector(2, "样品平衡","sense_inspector_sign_balance","感官检验负责人", new QmsWorkorderSampleBalance(), "senseInspectorSign"),
    b_d_tester(0, "取送样品交接","delivery_tester_sign", "测试人员(交接时)",new QmsWorkorderSampleBalance(), "deliveryTesterSign"),
    b_d_auditor(0, "取送样品交接","delivery_auditor_sign", "审核人员(交接时)",new QmsWorkorderSampleBalance(), "deliveryAuditorSign"),
    b_b_tester(2, "样品平衡","before_tester_sign", "测试人员(平衡前)",new QmsWorkorderSampleBalance(), "beforeTesterSign"),
    b_b_auditor(2, "样品平衡","before_auditor_sign", "审核人员(平衡前)",new QmsWorkorderSampleBalance(), "beforeAuditorSign"),
    b_a_tester(2, "样品平衡","after_tester_sign", "测试人员(平衡后)",new QmsWorkorderSampleBalance(), "afterTesterSign"),
    b_a_auditor(2, "样品平衡","after_auditor_sign", "审核人员(平衡后)",new QmsWorkorderSampleBalance(), "afterAuditorSign"),
    h_principal(3, "HVI检验","principal_sign_hvi", "HVI 检验负责人",new QmsWorkorderHvi(), "principalSign"),
    h_r_operator(3, "HVI检验","operator_sign", "操作人员",new QmsWorkorderHviRecord(), "operatorSign"),
    h_r_team(3, "HVI检验","team_leader_sign", "班组负责人",new QmsWorkorderHviRecord(), "teamLeaderSign"),
    a_principal(4, "数据审核","principal_sign_audit", "技术负责人或其授权人",new QmsWorkorderAudit(), "principalSign"),
    a_admin(4, "数据审核","sys_admin_sign_audit","信息系统管理员", new QmsWorkorderAudit(), "sysAdminSign"),
    ;

    private final Integer orderStatus;
    private final String stepName;
    private final String column;
    private final String columnName;
    private final Object wrapper;
    private final String code;

    SignTypeEnum(Integer orderStatus, String stepName, String column, String columnName, Object wrapper, String code) {
        this.orderStatus = orderStatus;
        this.stepName = stepName;
        this.column = column;
        this.columnName = columnName;
        this.wrapper = wrapper;
        this.code = code;
    }

    public Integer getOrderStatus() {
        return orderStatus;
    }

    public String getStepName() {
        return stepName;
    }

    public String getColumn() {
        return column;
    }

    public String getColumnName() {
        return columnName;
    }

    public Object getWrapper() {
        return wrapper;
    }

    public String getCode() {
        return code;
    }
    public static SignTypeEnum getByCodeAndOrderStatus(String code, Integer orderStatus) {
        for (SignTypeEnum value : values()) {
            if (value.getCode().equals(code)) {
                if (value.getOrderStatus().equals(orderStatus)){
                    return value;
                }
            }
        }
        return null;
    }

    public static List<SignTypeEnum> getAllByCode(String code) {
        ArrayList<SignTypeEnum> arrayList = new ArrayList<>();
        String columnName = "";
        for (SignTypeEnum value : values()) {
            if (value.getCode().equals(code)) {
                columnName = value.getColumnName();
            }
        }

        for (SignTypeEnum value : values()) {
            if (value.getColumnName().equals(columnName)){
                arrayList.add(value);
            }
        }
        return arrayList;
    }
}
